<template>
  <DataList 
  :cate="cate" 
  :cols="cols"
  :excelHeader="excelHeader"
  skipExcelNumber="2"
  :name="name" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import linq from "linq";
import { addZdzdcx, deleteZdzdcx, updateZdzdcx, getZdzdcx ,bulkAddZdzdcx} from "@/api/重大制度创新.js";
import { mkdir } from 'fs';
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A8-9重大制度创新表",
      name:'8.9 重大制度创新',
       excelHeader:{B3:"项目名称(全称)",C3:"主要创新点",D3:"实施日期（年月）",E3:"主要成果"},
      cols: [
        
        { label: "项目名称(全称)", prop: "ZDZDCSXMMC" },
        { label: "主要创新点", prop: "ZYCSD"},
        { label: "实施日期(年月)", prop: "XSRQ"},
        { label: "主要成果", prop: "ZYCG"},
      ]
    };
  },
  methods: {
     getSummaries(list){
      //
        const sums = [];
         this.cols.forEach((column, index) => {
            sums[index]="";
        });
        sums[2]= "项目数:"+linq.from(list).count("$.ZDZDCSXMMC");
        return sums;
        },
  
 check(array,list) {
     return new Promise(async (resolve,reject)=>{
       resolve();
     })
 },
    async fetchData() {
      var user = getUser();
      var datas = await getZdzdcx(user.XXID,user.CJPC);
      return datas;
    },
     onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addZdzdcx(temp);
          resolve(model);
      })
      
    },
    async  bulkAdd(array){
       await  bulkAddZdzdcx({Zdzdcx:array});
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateZdzdcx(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteZdzdcx(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>